9834a4e4557417e1267dfec396b523486027d552,src/main/java/net/floodlightcontroller/forwarding/Forwarding.java,Forwarding,createMatchFromPacket,#IOFSwitch#OFPort#FloodlightContext#,404
Before Change
MacAddress dstMac = eth.getDestinationMACAddress();
Match.Builder mb = sw.getOFFactory().buildMatch();
mb.setExact(MatchField.IN_PORT, inPort);
if (FLOWMOD_DEFAULT_MATCH_MAC) {
mb.setExact(MatchField.ETH_SRC, srcMac)
.setExact(MatchField.ETH_DST, dstMac);
}
if (FLOWMOD_DEFAULT_MATCH_VLAN) {
if (!vlan.equals(VlanVid.ZERO)) {
mb.setExact(MatchField.VLAN_VID, OFVlanVidMatch.ofVlanVid(vlan));
}
}
// TODO Detect switch type and match to create hardware-implemented flow
if (eth.getEtherType() == EthType.IPv4) { /* shallow check for equality is okay for EthType */
IPv4 ip = (IPv4) eth.getPayload();
IPv4Address srcIp = ip.getSourceAddress();
IPv4Address dstIp = ip.getDestinationAddress();
if (FLOWMOD_DEFAULT_MATCH_IP_ADDR) {
mb.setExact(MatchField.ETH_TYPE, EthType.IPv4)
.setExact(MatchField.IPV4_SRC, srcIp)
.setExact(MatchField.IPV4_DST, dstIp);
}
if (FLOWMOD_DEFAULT_MATCH_TRANSPORT) {
/*
* Take care of the ethertype if not included earlier,
* since it's a prerequisite for transport ports.
*/
if (!FLOWMOD_DEFAULT_MATCH_IP_ADDR) {
mb.setExact(MatchField.ETH_TYPE, EthType.IPv4);
}
if (ip.getProtocol().equals(IpProtocol.TCP)) {
TCP tcp = (TCP) ip.getPayload();
mb.setExact(MatchField.IP_PROTO, IpProtocol.TCP)
.setExact(MatchField.TCP_SRC, tcp.getSourcePort())
.setExact(MatchField.TCP_DST, tcp.getDestinationPort());
} else if (ip.getProtocol().equals(IpProtocol.UDP)) {
UDP udp = (UDP) ip.getPayload();
mb.setExact(MatchField.IP_PROTO, IpProtocol.UDP)
.setExact(MatchField.UDP_SRC, udp.getSourcePort())
.setExact(MatchField.UDP_DST, udp.getDestinationPort());
}
}
} else if (eth.getEtherType() == EthType.ARP) { /* shallow check for equality is okay for EthType */
After Change
MacAddress dstMac = eth.getDestinationMACAddress();
Match.Builder mb = sw.getOFFactory().buildMatch();
if (FLOWMOD_DEFAULT_MATCH_IN_PORT) {
mb.setExact(MatchField.IN_PORT, inPort);
}
if (FLOWMOD_DEFAULT_MATCH_MAC) {
if (FLOWMOD_DEFAULT_MATCH_MAC_SRC) {
mb.setExact(MatchField.ETH_SRC, srcMac);
}
if (FLOWMOD_DEFAULT_MATCH_MAC_DST) {
mb.setExact(MatchField.ETH_DST, dstMac);
}
}
if (FLOWMOD_DEFAULT_MATCH_VLAN) {
if (!vlan.equals(VlanVid.ZERO)) {
mb.setExact(MatchField.VLAN_VID, OFVlanVidMatch.ofVlanVid(vlan));
}
}
// TODO Detect switch type and match to create hardware-implemented flow
if (eth.getEtherType() == EthType.IPv4) { /* shallow check for equality is okay for EthType */
IPv4 ip = (IPv4) eth.getPayload();
IPv4Address srcIp = ip.getSourceAddress();
IPv4Address dstIp = ip.getDestinationAddress();
if (FLOWMOD_DEFAULT_MATCH_IP) {
mb.setExact(MatchField.ETH_TYPE, EthType.IPv4);
if (FLOWMOD_DEFAULT_MATCH_IP_SRC) {
mb.setExact(MatchField.IPV4_SRC, srcIp);
}
if (FLOWMOD_DEFAULT_MATCH_IP_DST) {
mb.setExact(MatchField.IPV4_DST, dstIp);
}
}
if (FLOWMOD_DEFAULT_MATCH_TRANSPORT) {
/*
* Take care of the ethertype if not included earlier,
* since it's a prerequisite for transport ports.
*/
if (!FLOWMOD_DEFAULT_MATCH_IP) {
mb.setExact(MatchField.ETH_TYPE, EthType.IPv4);
}
if (ip.getProtocol().equals(IpProtocol.TCP)) {
TCP tcp = (TCP) ip.getPayload();
mb.setExact(MatchField.IP_PROTO, IpProtocol.TCP);
if (FLOWMOD_DEFAULT_MATCH_TRANSPORT_SRC) {
mb.setExact(MatchField.TCP_SRC, tcp.getSourcePort());
}
if (FLOWMOD_DEFAULT_MATCH_TRANSPORT_DST) {
mb.setExact(MatchField.TCP_DST, tcp.getDestinationPort());
}
} else if (ip.getProtocol().equals(IpProtocol.UDP)) {
UDP udp = (UDP) ip.getPayload();
mb.setExact(MatchField.IP_PROTO, IpProtocol.UDP);
if (FLOWMOD_DEFAULT_MATCH_TRANSPORT_SRC) {
mb.setExact(MatchField.UDP_SRC, udp.getSourcePort());
}
if (FLOWMOD_DEFAULT_MATCH_TRANSPORT_DST) {
mb.setExact(MatchField.UDP_DST, udp.getDestinationPort());
}
}
}